﻿@using StackExchange.Opserver.Data.Dashboard
@using StackExchange.Opserver.Models
@using StackExchange.Opserver.Views.Dashboard
@model Node
@{
    var s = Model;
}
@functions
{
    public string GetItemClass(Node s)
    {
        var prefix = s.IsVM ? "virtual-machine " : "";
        return prefix + s.MonitorStatus.RowClass();
    }
}
@helper Graph(Node s, string type)
{
    if (!DashboardData.HasData)
    {
        <div class="spark-no-data">No Data Available</div>
        return;
    }
    <img class="dashboard-spark" src="/graph/@type.ToLower()/spark?id=@s.Id"  width="@Current.ViewSettings.SparklineChartWidth" height="@Current.ViewSettings.SparklineChartHeight" alt="" data-id="@s.Id" data-title="@type" data-node="@s.PrettyName" />
}
<div class="item @s.MonitorStatus.Class() @GetItemClass(s)">
    <div class="server-name">
        @s.IconSpan()
        <a href="/dashboard/node?node=@s.PrettyName" class="node-name-link">@s.PrettyName</a>
        @if (s.IsUnwatched)
        {
            <span class="unmanaged">(unmanaged)</span>
        }
        <span class="category">@s.Category.Name</span>
    </div>
    <div class="status-block cpu-status">
        <span class="label">CPU </span>@s.CPUStatusSpan() 
        <div class="status-graph">@Graph(s, "CPU")</div>
    </div>
    <div class="status-block mem-status">
        <span class="label">Mem </span>@s.MemoryPercentStatusSpan()
        <div class="status-graph">@s.MemoryStatusSpan()@if (s.HasValidMemoryReading) {
            <div class="space-used" style="width: 215px;"><div class="used @s.MemoryMonitorStatus().GetDescription()" style="width:@(s.PercentMemoryUsed)%"></div></div>
        }
        </div>
    </div>
    <div class="status-block net-status">
        <span class="label">Net </span>@s.PrettyTotalNetwork() 
        <div class="status-graph"><a href="/dashboard/node?node=@s.PrettyName&view=@CurrentStatusTypes.Interfaces">@Graph(s, "Network")</a></div>
    </div>
</div>